package net.pessu.android.shoppoid.gui;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class ButtonRemiseLayout extends LinearLayout {

	public ButtonRemiseLayout(Context context) {
		super(context);
	}

	public ButtonRemiseLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void initializeButtons() {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			currentButton.unSelect();
		}
	}

	public ButtonList getSelectedButton() {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			if (currentButton.isSelected()) {
				return currentButton;
			}
		}
		return null;
	}

	public void selectButton(double taux) {
		ButtonList currentButton;
		for (int i = 0; i < getChildCount(); i++) {
			currentButton = (ButtonList) getChildAt(i);
			if (currentButton.getTaux() == taux) {
				currentButton.select();
			}
		}
	}

}
